import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/17 16:13
 * @description 自定义排序
 */
public class Solution2 {
    public static void main(String[] args) {

    }
    public int findClosestNumber(int[] nums) {
        List<Integer> list = new ArrayList<>();
        for (int n:  nums) {
            list.add(n);
        }
        Collections.sort(list, (a, b) -> {
            if (Math.abs(a) == Math.abs(b)) {
                return b-a;
            }
            return Math.abs(a) - Math.abs(b);
        });
        return list.get(0);
    }
}
